<template>
	<div id="allmap">
	</div>
</template>

<script>
	import { MP } from '@/assets/js/map'
	export default {
	components: {
	},
	methods: {
		nav: function() {

		}
	},
	mounted: function() {
			this.nav();

			this.$nextTick(function() {
						var _this = this;
						MP(_this.ak).then(function(BMap) {
									// 百度地图API功能
									var map = new BMap.Map("allmap");
									/*以下写获取位置信息的代码*/
									var geolocation = new BMap.Geolocation();
        geolocation.getCurrentPosition(function(r) {
            if(this.getStatus() == BMAP_STATUS_SUCCESS) {
                var mk = new BMap.Marker(r.point);
                getAddress(r.point);
            } else {
                alert('failed' + this.getStatus());
            }
        });
        /*获取地址信息，设置地址label*/
        function getAddress(point) {
            var gc = new BMap.Geocoder();
            gc.getLocation(point, function(rs) {
                var addComp = rs.addressComponents;
                /*获取地址*/
                var address = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber; 
                alert(address);
            });
        }


    });
});
		}
			
	}
</script>

<style>

</style>